home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / librw / RWCollection.z / RWCollection
Encoding:
Text File  |  1998-10-30  |  15.3 KB  |  397 lines

  1.  
  2.  
  3.  
  4. RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn((((3333CCCC++++++++))))                                          RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      RWCollection - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               #include <rw/colclass.h>
  13.  
  14.  
  15.  
  16.               typedef RWCollection Collection;   // Smalltalk typedef
  17.  
  18.  
  19.  
  20.  
  21. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
  22.      Class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn is an abstract base class for the Smalltalk-like
  23.      collection classes.  The class contains virtual functions for inserting
  24.      and retrieving pointers to RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee objects into the collection
  25.      classes.  Virtual functions are also provided for storing and reading the
  26.      collections to files and streams.  Collections that inherit this base
  27.      class will typically redefine one or more of these functions.  In the
  28.      documentation below, pure virtual functions are indicated by "= 0" in
  29.      their declaration.  These functions mmmmuuuusssstttt bbbbeeee defined in derived classes.
  30.      For these functions the description is intended to be generic -- all
  31.      inheriting collection classes generally follow the described pattern.
  32.      Exceptions are noted in the documentation for the particular class.  For
  33.      many other functions, a suitable definition is provided by RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn
  34.      and a deriving class may not need to redefine the function.  Examples are
  35.      ccccoooonnnnttttaaaaiiiinnnnssss(((()))) or rrrreeeessssttttoooorrrreeeeGGGGuuuuttttssss(((()))).
  36.  
  37. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
  38.      Polymorphic
  39.  
  40. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr OOOOppppeeeerrrraaaattttoooorrrrssss
  41.               void
  42.           ooooppppeeeerrrraaaattttoooorrrr++++====(const RWCollection&);
  43.           void
  44.           ooooppppeeeerrrraaaattttoooorrrr----====(const RWCollection&);
  45.  
  46.  
  47.      Adds or removes, respectively, each item in the argument to or from self.
  48.      Using ooooppppeeeerrrraaaattttoooorrrr++++====((((ssssoooommmmeeeePPPPrrrreeeeSSSSoooorrrrtttteeeeddddCCCCoooolllllllleeeeccccttttiiiioooonnnn)))) on an RRRRWWWWBBBBiiiinnnnaaaarrrryyyyTTTTrrrreeeeeeee can cause
  49.      that tree to become unbalanced; possibly to the point of stack overflow.
  50.  
  51. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  52.               virtual
  53.           ~~~~RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn();
  54.  
  55.  
  56.      Null definition (does nothing).
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn((((3333CCCC++++++++))))                                          RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74.               virtual void
  75.           aaaappppppppllllyyyy(RWapplyCollectable ap, void*) = 0;
  76.  
  77.  
  78.      This function applies the user-supplied function pointed to by aaaapppp to each
  79.      member of the collection.  This function should have prototype
  80.  
  81.               void yyyyoooouuuurrrrAAAAppppppppllllyyyyFFFFuuuunnnnccccttttiiiioooonnnn(RWCollectable* ctp, void*);
  82.  
  83.  
  84.  
  85.  
  86.  
  87.      The function yyyyoooouuuurrrrAAAAppppppppllllyyyyFFFFuuuunnnnccccttttiiiioooonnnn(((()))) can perform any operation on the item at
  88.      address ccccttttpppp that ddddooooeeeessss nnnnooootttt cccchhhhaaaannnnggggeeee the hash value or sorting order of the
  89.      item.  Client data may be passed to this function through the second
  90.      argument.
  91.  
  92.               RWBag
  93.           aaaassssBBBBaaaagggg() const;
  94.           RWSet
  95.           aaaassssSSSSeeeetttt() const;
  96.           RWOrdered
  97.           aaaassssOOOOrrrrddddeeeerrrreeeeddddCCCCoooolllllllleeeeccccttttiiiioooonnnn() const;
  98.           RWBinaryTree
  99.           aaaassssSSSSoooorrrrtttteeeeddddCCCCoooolllllllleeeeccccttttiiiioooonnnn() const;
  100.  
  101.  
  102.      Allows any collection to be converted to an RRRRWWWWBBBBaaaagggg, RRRRWWWWSSSSeeeetttt, RRRRWWWWOOOOrrrrddddeeeerrrreeeedddd, or
  103.      an RRRRWWWWBBBBiiiinnnnaaaarrrryyyyTTTTrrrreeeeeeee.  Note that the return value is a ccccooooppppyyyy of the data. This
  104.      can be very expensive for large collections.  You should consider using
  105.      ooooppppeeeerrrraaaattttoooorrrr++++====(((()))) to insert each item from this collection into a collection
  106.      of your choice.  Also note that converting a collection containing data
  107.      which is already sorted to a RRRRWWWWBBBBiiiinnnnaaaarrrryyyyTTTTrrrreeeeeeee via the aaaassssSSSSoooorrrrtttteeeeddddCCCCoooolllllllleeeeccccttttiiiioooonnnn(((()))) or
  108.      aaaassssBBBBiiiinnnnaaaarrrryyyyTTTTrrrreeeeeeee(((()))) methods will build a very unbalanced tree.
  109.  
  110.               virtual RWspace
  111.           bbbbiiiinnnnaaaarrrryyyySSSSttttoooorrrreeeeSSSSiiiizzzzeeee() const;
  112.  
  113.  
  114.      Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee.
  115.  
  116.               virtual void
  117.           cccclllleeeeaaaarrrr() = 0;
  118.  
  119.  
  120.      Removes all objects from the collection.  Does not delete the objects
  121.      themselves.
  122.  
  123.               virtual void
  124.           cccclllleeeeaaaarrrrAAAAnnnnddddDDDDeeeessssttttrrrrooooyyyy();
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn((((3333CCCC++++++++))))                                          RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140.      Removes all objects from the collection aaaannnndddd ddddeeeelllleeeetttteeeessss them.  Takes into
  141.      account duplicate objects within a collection and only deletes them once.
  142.      However, it does nnnnooootttt take into account objects shared between different
  143.      collections.  Either do not use this function if you will be sharing
  144.      objects between separate collections, or put all collections that could
  145.      be sharing objects into one single "super-collection" and call
  146.      cccclllleeeeaaaarrrrAAAAnnnnddddDDDDeeeessssttttrrrrooooyyyy(((()))) on that.
  147.  
  148.               virtual int
  149.           ccccoooommmmppppaaaarrrreeeeTTTToooo(const RWCollectable* a) const;
  150.  
  151.  
  152.      Inherited from class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee.
  153.  
  154.               virtual RWBoolean
  155.           ccccoooonnnnttttaaaaiiiinnnnssss(const RWCollectable* target) const;
  156.  
  157.  
  158.      Returns TTTTRRRRUUUUEEEE if the collection contains an item where the virtual
  159.      function ffffiiiinnnndddd(((()))) returns non-nil.
  160.  
  161.               virtual size_t
  162.           eeeennnnttttrrrriiiieeeessss() const = 0;
  163.  
  164.  
  165.      Returns the total number of items in the collection.
  166.  
  167.               virtual RWCollectable*
  168.           ffffiiiinnnndddd(const RWCollectable* target) const = 0;
  169.  
  170.  
  171.      Returns a pointer to the first item in the collection which "matches" the
  172.      object pointed to by ttttaaaarrrrggggeeeetttt or nnnniiiillll if no item was found.  For most
  173.      collections, an item "matches" the target if either iiiissssEEEEqqqquuuuaaaallll(((()))) or
  174.      ccccoooommmmppppaaaarrrreeeeTTTToooo(((()))) find equivalence, whichever is appropriate for the actual
  175.      collection type.  However, the "identity collections" (iiii....eeee....,
  176.      RRRRWWWWIIIIddddeeeennnnttttiiiittttyyyySSSSeeeetttt and RRRRWWWWIIIIddddeeeennnnttttiiiittttyyyyDDDDiiiiccccttttiiiioooonnnnaaaarrrryyyy) look for an item with the same
  177.      address (iiii....eeee...., "is identical to").
  178.  
  179.               virtual unsigned
  180.           hhhhaaaasssshhhh() const;
  181.  
  182.  
  183.      Inherited from class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee.
  184.  
  185.               virtual RWCollectable*
  186.           iiiinnnnsssseeeerrrrtttt(RWCollectable* e) = 0;
  187.  
  188.  
  189.      Adds an item to the collection and returns a pointer to it.  If the item
  190.      is already in the collection, some collections derived from RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn
  191.      return the old instance, others return nnnniiiillll.
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn((((3333CCCC++++++++))))                                          RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn((((3333CCCC++++++++))))
  203.  
  204.  
  205.  
  206.               virtual RWClassID
  207.           iiiissssAAAA() const;
  208.  
  209.  
  210.      Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee to return ________RRRRWWWWCCCCOOOOLLLLLLLLEEEECCCCTTTTIIIIOOOONNNN.
  211.  
  212.               virtual RWBoolean
  213.           iiiissssEEEEmmmmppppttttyyyy() const = 0;
  214.  
  215.  
  216.      Returns TTTTRRRRUUUUEEEE if the collection is empty, otherwise returns FFFFAAAALLLLSSSSEEEE.
  217.  
  218.               virtual RWBoolean
  219.           iiiissssEEEEqqqquuuuaaaallll(const RWCollectable* a) const;
  220.  
  221.  
  222.      Inherited from class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee.
  223.  
  224.               virtual size_t
  225.           ooooccccccccuuuurrrrrrrreeeennnncccceeeessssOOOOffff(const RWCollectable* t) const = 0;
  226.  
  227.  
  228.      Returns the number of items in the collection which are "matches" tttt.  See
  229.      function ffffiiiinnnndddd(((()))) for a definition of matches.
  230.  
  231.               virtual void
  232.           rrrreeeessssttttoooorrrreeeeGGGGuuuuttttssss(RWFile&);
  233.  
  234.  
  235.      Redefined to repeatedly call the global operator
  236.  
  237.               RWFile& operator>>(RWFile&, RWCollectable*&);
  238.  
  239.  
  240.  
  241.  
  242.  
  243.      followed by iiiinnnnsssseeeerrrrtttt((((RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee****)))) for each item in the collection.
  244.  
  245.               virtual void
  246.           rrrreeeessssttttoooorrrreeeeGGGGuuuuttttssss(RWvistream&);
  247.  
  248.  
  249.      Redefined to repeatedly call the global operator
  250.  
  251.               RWvistream& operator>>(RWvistream&, RWCollectable*&);
  252.  
  253.  
  254.  
  255.  
  256.  
  257.      followed by iiiinnnnsssseeeerrrrtttt((((RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee****)))) for each item in the collection.
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn((((3333CCCC++++++++))))                                          RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn((((3333CCCC++++++++))))
  269.  
  270.  
  271.  
  272.               RWCollectable*
  273.           rrrreeeemmmmoooovvvveeee(const RWCollectable* target) = 0;
  274.  
  275.  
  276.      Removes and returns a pointer to the first item in the collection which
  277.      "matches" the object pointed to by ttttaaaarrrrggggeeeetttt.  Returns nnnniiiillll if no object was
  278.      found.  Does not delete the object.
  279.  
  280.               virtual void
  281.           rrrreeeemmmmoooovvvveeeeAAAAnnnnddddDDDDeeeessssttttrrrrooooyyyy(const RWCollectable* target);
  282.  
  283.  
  284.      Removes aaaannnndddd ddddeeeelllleeeetttteeeessss the first item in the collection which "matches" the
  285.      object pointed to by ttttaaaarrrrggggeeeetttt.
  286.  
  287.               RWCollection*
  288.           sssseeeelllleeeecccctttt(RWtestCollectable tst, void* x) const;
  289.  
  290.  
  291.      Evaluates the function pointed to by ttttsssstttt for each item in the collection.
  292.      It inserts those items for which the function returns TTTTRRRRUUUUEEEE into a new
  293.      collection allocated off the heap of the same type as self and returns a
  294.      pointer to this new collection.  Because the new collection is allocated
  295.      ooooffffffff tttthhhheeee hhhheeeeaaaapppp, you are responsible for deleting it when done.  This is not
  296.      a virtual function.
  297.  
  298.               virtual void
  299.           ssssaaaavvvveeeeGGGGuuuuttttssss(RWFile&);
  300.  
  301.  
  302.      Redefined to call the global operator
  303.  
  304.               RWFile& operator<<(RWFile&, const RWCollectable&);
  305.  
  306.  
  307.  
  308.  
  309.  
  310.      for each object in the collection.
  311.  
  312.               virtual void
  313.           ssssaaaavvvveeeeGGGGuuuuttttssss(RWvostream&);
  314.  
  315.  
  316.      Redefined to call the global operator
  317.  
  318.               RWvostream& operator<<(RWvostream&, const RWCollectable&);
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn((((3333CCCC++++++++))))                                          RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn((((3333CCCC++++++++))))
  335.  
  336.  
  337.  
  338.  
  339.  
  340.      for each object in the collection.
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.                                                                         PPPPaaaaggggeeee 6666
  394.  
  395.  
  396.  
  397.